package com.yjian.auth;

import com.yjian.service.UserService;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by xuxiaobao on 2017/10/1.
 */
@Component
public class AuthService {
    @Autowired
    private UserService userService;

    @Autowired
    private TokenRequestHeader tokenRequestHeader;

    public String getUidFromRequestHeader(HttpServletRequest httpServletRequest) {
        String token = tokenRequestHeader.getToken(httpServletRequest);
        //token解码
        return StringUtils.newStringUtf8(Base64.decodeBase64(token));
    }
}
